package zj;

import java.util.Scanner;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/7/31 13:59
 */
public class Solution2 {

    //  一会考虑边界条件
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int[] arr = new int[8];
        int[] Ax = new int[2];
        int[] Ay = new int[2];
        int[] Bx = new int[2];
        int[] By = new int[2];
        for(int i = 0; i < 8; i++){
            arr[i] = in.nextInt();
        }
        Ax[0] = arr[0];
        Ax[1] = arr[2];
        Ay[0] = arr[1];
        Ay[1] = arr[3];
        Bx[0] = arr[4];
        Bx[1] = arr[6];
        By[0] = arr[5];
        By[1] = arr[7];

        int res = inner(Ax, Bx) && inner(Ay, By) ? 1 : 0;
        System.out.println(res);
    }

    // 判断两个数据是否有交点
    private static boolean inner(int[] a1, int[] a2){
        if(a1[0] == a2[0] || a1[1] == a2[1]) return true;
        if(a1[0] > a2[0]){
            return a1[0] <= a2[1];    //如果边相交不算相交的话，就把等号去掉
        }else{
            return a2[0] <= a1[1];    //如果边相交不算相交的话，就把等号去掉
        }
    }
}
